package com.hspedu.tankgame5;


import javax.swing.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Scanner;

/**
 * @author LiuJinTao
 * @className TankGame01
 * @date 2024/06/20 17:42
 * @description TODO
 */
public class TankGame04 extends JFrame {
    // 定义一个 MyPanel
    MyPanel mp = null;
    static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
        new TankGame04();

    }

    public TankGame04() {
        System.out.println("请输入选择  1：新游戏 2：继续上局");
        String key = scan.next();
        mp = new MyPanel(key);
        Thread thread = new Thread(mp);
        thread.start();
        this.add(mp);
        this.addKeyListener(mp);
        this.setSize(1350, 750);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);

        // 增加响应窗口关闭的处理
        this.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                Recorder.keepRecord();
                System.exit(0);
            }
        });
    }
}
